﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using BPM.Base.WFLib.Designer;
using System.Workflow.ComponentModel;

namespace BPM.Base.WFLib.GuideForm
{
	public partial class ChildWorkflowForm: Form
	{
        public 调用子流程 activity;
        public ChildWorkflowForm(CallWorkflowDesigner designer)
		{
			InitializeComponent();
            activity = designer.Activity as 调用子流程;
            this.回归主流程.Checked  = activity.回归主流程;
            this.子流程模板版本.Text = activity.子流程模板版本;
            this.子流程模板编号.Text = activity.子流程模板编号;
		}

        private void button1_Click(object sender, EventArgs e)
        {
            this.Close();
        }

        private void button2_Click(object sender, EventArgs e)
        {
            activity.回归主流程 = this.回归主流程.Checked;
            activity.子流程模板版本 =this.子流程模板版本.Text ;
            activity.子流程模板编号=this.子流程模板编号.Text  ;

                try
                {
                    {
                        System.Workflow.ComponentModel.ActivityBind activitybind1 = new System.Workflow.ComponentModel.ActivityBind();
                        activitybind1.Path = "流程编号";
                        activitybind1.Name = Root().Name;
                        activity.SetBinding(调用子流程.主流程编号Property, activitybind1);

                    }

                    {
                        System.Workflow.ComponentModel.ActivityBind activitybind1 = new System.Workflow.ComponentModel.ActivityBind();
                        activitybind1.Path = "业务类型";
                        activitybind1.Name = Root().Name;
                        activity.SetBinding(调用子流程.业务类型Property, activitybind1);

                    }
                    {
                        System.Workflow.ComponentModel.ActivityBind activitybind1 = new System.Workflow.ComponentModel.ActivityBind();
                        activitybind1.Path = "业务编号";
                        activitybind1.Name = Root().Name;
                        activity.SetBinding(调用子流程.业务编号Property, activitybind1);

                    }
                    {
                        System.Workflow.ComponentModel.ActivityBind activitybind1 = new System.Workflow.ComponentModel.ActivityBind();
                        activitybind1.Path = "主业务编号";
                        activitybind1.Name = Root().Name;
                        activity.SetBinding(调用子流程.主业务编号Property, activitybind1);

                    }
                    {
                        System.Workflow.ComponentModel.ActivityBind activitybind1 = new System.Workflow.ComponentModel.ActivityBind();
                        activitybind1.Path = "业务名称";
                        activitybind1.Name = Root().Name;
                        activity.SetBinding(调用子流程.业务名称Property, activitybind1);

                    }
                    {
                        System.Workflow.ComponentModel.ActivityBind activitybind1 = new System.Workflow.ComponentModel.ActivityBind();
                        activitybind1.Path = "业务描述";
                        activitybind1.Name = Root().Name;
                        activity.SetBinding(调用子流程.业务描述Property, activitybind1);

                    }
                    {
                        System.Workflow.ComponentModel.ActivityBind activitybind1 = new System.Workflow.ComponentModel.ActivityBind();
                        activitybind1.Path = "业务紧急度";
                        activitybind1.Name = Root().Name;
                        activity.SetBinding(调用子流程.业务紧急度Property, activitybind1);

                    }
                    {
                        System.Workflow.ComponentModel.ActivityBind activitybind1 = new System.Workflow.ComponentModel.ActivityBind();
                        activitybind1.Path = "业务保密度";
                        activitybind1.Name = Root().Name;
                        activity.SetBinding(调用子流程.业务保密度Property, activitybind1);

                    }
                    {
                        System.Workflow.ComponentModel.ActivityBind activitybind1 = new System.Workflow.ComponentModel.ActivityBind();
                        activitybind1.Path = "启动人员";
                        activitybind1.Name = Root().Name;
                        activity.SetBinding(调用子流程.启动人员Property, activitybind1);

                    }
                    {
                        System.Workflow.ComponentModel.ActivityBind activitybind1 = new System.Workflow.ComponentModel.ActivityBind();
                        activitybind1.Path = "启动部门";
                        activitybind1.Name = Root().Name;
                        activity.SetBinding(调用子流程.启动部门Property, activitybind1);

                    }
                    {
                        System.Workflow.ComponentModel.ActivityBind activitybind1 = new System.Workflow.ComponentModel.ActivityBind();
                        activitybind1.Path = "启动职能";
                        activitybind1.Name = Root().Name;
                        activity.SetBinding(调用子流程.启动职能Property, activitybind1);

                    }
                    {
                        System.Workflow.ComponentModel.ActivityBind activitybind1 = new System.Workflow.ComponentModel.ActivityBind();
                        activitybind1.Path = "启动时间";
                        activitybind1.Name = Root().Name;
                        activity.SetBinding(调用子流程.启动时间Property, activitybind1);

                    }

                    {
                        System.Workflow.ComponentModel.ActivityBind activitybind1 = new System.Workflow.ComponentModel.ActivityBind();
                        activitybind1.Path = "测试编号";
                        activitybind1.Name = Root().Name;
                        activity.SetBinding(调用子流程.测试编号Property, activitybind1);

                    }




                }
                catch
                {
                }

              this.Close();
        }


        //[2.4.1]
        状态机模板 Root()
        {
            Activity o = activity;

            while (o.Parent != null)
            {
                o = o.Parent;
            }
            状态机模板 tp = o as 状态机模板;

            if (tp != null)
            {
                return tp;
            }
            else
            {
                throw new System.Exception("GetRoot");
            }

        }

        private void button3_Click(object sender, EventArgs e)
        {
            activity.回归主流程 = this.回归主流程.Checked;
            activity.子流程模板版本 = this.子流程模板版本.Text;
            activity.子流程模板编号 = this.子流程模板编号.Text;

            try
            {
                {
                    System.Workflow.ComponentModel.ActivityBind activitybind1 = new System.Workflow.ComponentModel.ActivityBind();
                    activitybind1.Path = "流程编号";
                    activitybind1.Name = Root().Name;
                    activity.SetBinding(调用子流程.主流程编号Property, activitybind1);

                }

                {
                    System.Workflow.ComponentModel.ActivityBind activitybind1 = new System.Workflow.ComponentModel.ActivityBind();
                    activitybind1.Path = "业务类型";
                    activitybind1.Name = Root().Name;
                    activity.SetBinding(调用子流程.业务类型Property, activitybind1);

                }
                {
                    System.Workflow.ComponentModel.ActivityBind activitybind1 = new System.Workflow.ComponentModel.ActivityBind();
                    activitybind1.Path = "业务编号";
                    activitybind1.Name = Root().Name;
                    activity.SetBinding(调用子流程.业务编号Property, activitybind1);

                }
                {
                    System.Workflow.ComponentModel.ActivityBind activitybind1 = new System.Workflow.ComponentModel.ActivityBind();
                    activitybind1.Path = "主业务编号";
                    activitybind1.Name = Root().Name;
                    activity.SetBinding(调用子流程.主业务编号Property, activitybind1);

                }
                {
                    System.Workflow.ComponentModel.ActivityBind activitybind1 = new System.Workflow.ComponentModel.ActivityBind();
                    activitybind1.Path = "业务名称";
                    activitybind1.Name = Root().Name;
                    activity.SetBinding(调用子流程.业务名称Property, activitybind1);
                    
                }
                {
                    System.Workflow.ComponentModel.ActivityBind activitybind1 = new System.Workflow.ComponentModel.ActivityBind();
                    activitybind1.Path = "业务描述";
                    activitybind1.Name = Root().Name;
                    activity.SetBinding(调用子流程.业务描述Property, activitybind1);
                    
                }
                {
                    System.Workflow.ComponentModel.ActivityBind activitybind1 = new System.Workflow.ComponentModel.ActivityBind();
                    activitybind1.Path = "业务紧急度";
                    activitybind1.Name = Root().Name;
                    activity.SetBinding(调用子流程.业务紧急度Property, activitybind1);
                    
                }
                {
                    System.Workflow.ComponentModel.ActivityBind activitybind1 = new System.Workflow.ComponentModel.ActivityBind();
                    activitybind1.Path = "业务保密度";
                    activitybind1.Name = Root().Name;
                    activity.SetBinding(调用子流程.业务保密度Property, activitybind1);
                   
                }
                {
   
                     activity.启动人员 = "";
                }
                {
 
                    activity.启动部门 = "";
                }
                {
 
                    activity.启动职能 = "";
                }
                {

                    System.Workflow.ComponentModel.ActivityBind activitybind1 = new System.Workflow.ComponentModel.ActivityBind();
                    activitybind1.Path = "启动时间";
                    activitybind1.Name = Root().Name;
                    activity.SetBinding(调用子流程.启动时间Property, activitybind1);
                }

                {

                    System.Workflow.ComponentModel.ActivityBind activitybind1 = new System.Workflow.ComponentModel.ActivityBind();
                    activitybind1.Path = "测试编号";
                    activitybind1.Name = Root().Name;
                    activity.SetBinding(调用子流程.测试编号Property, activitybind1);

                }




            }
            catch
            {
            }

            this.Close();
        }

        private void button4_Click(object sender, EventArgs e)
        {
            WFBrowseForm obj = new WFBrowseForm();
            obj.ShowDialog();
            if (string.IsNullOrEmpty(obj.fileName))
            {
                obj.Close();
                return;
            }
            if (string.IsNullOrEmpty(obj.edition))
            {
                obj.Close();
                return;
            }
             this.子流程模板版本.Text=obj.edition;
             this.子流程模板编号.Text=obj.fileName;
            obj.Close();
        }
	}
}
